package com.googlecode.jtoy.jee.jaxb;

/**
 * 错误消息
 * 
 * @author shangxj
 * @date Apr 17, 2011 6:30:02 PM
 */
public class Message {

	public static enum LEVEL {
		WARNING, ERROR, FATAL_ERROR
	}

	private LEVEL level;

	private int line;

	private int column;

	private String message;

	public Message() {

	}

	public Message(int severity, int line, int column, String message) {

		this.setLevel(severity == 0 ? LEVEL.WARNING : (severity == 1 ? LEVEL.ERROR
				: LEVEL.FATAL_ERROR));
		this.line = line;
		this.column = column;
		this.message = message;
	}

	/**
	 * (getter for line)
	 */
	public int getLine() {

		return this.line;
	}

	/**
	 * (setter for line)
	 */
	public void setLine(int line) {

		this.line = line;
	}

	/**
	 * (getter for column)
	 */
	public int getColumn() {

		return this.column;
	}

	/**
	 * (setter for column)
	 */
	public void setColumn(int column) {

		this.column = column;
	}

	/**
	 * (getter for message)
	 */
	public String getMessage() {

		return this.message;
	}

	/**
	 * (setter for message)
	 */
	public void setMessage(String message) {

		this.message = message;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {

		return String.format("[%s] (%d, %d) %s", this.level, this.line, this.column, this.message);
	}

	/**
	 * (setter for level)
	 */
	public void setLevel(LEVEL level) {

		this.level = level;
	}

	/**
	 * (getter for level)
	 */
	public LEVEL getLevel() {

		return level;
	}

}
